package com.easyCms.base.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import com.easyCms.base.entity.BsNav;

public interface BsNavDAO extends PagingAndSortingRepository<BsNav, Long>, JpaSpecificationExecutor<BsNav> {

	List<BsNav> findByState(int state);

	@Query("select bn from BsNav bn where bn.state = ?1 and bn.parentNavId is null order by bn.id DESC ")
	List<BsNav> findValidParentsNav(int stateValid);

	@Query("select bn from BsNav bn where bn.state = ?1 and bn.parentNavId=?2 order by bn.id DESC ")
	List<BsNav> findChildNav(int stateValid, Long parentNavId);

}
